#ifndef _MY_UART_H
#define _MY_UART_H

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include <string.h>


#define UART_PORT      (UART_NUM_2)
#define UART_PORT_TXD  (GPIO_NUM_17)
#define UART_PORT_RXD  (GPIO_NUM_16)
#define UART_PORT_RTS  (UART_PIN_NO_CHANGE)
#define UART_PORT_CTS  (UART_PIN_NO_CHANGE)

#define BUF_SIZE (1024)


//自定义交互格式
enum{
    UART_SET_TIME = 0xA1,
    UART_GET_TIME = 0xA2,
    UART_ONOFF = 0xA3,
    UART_GET_STATE = 0xA4,
    UART_GET_BATVAL = 0xB1,
    UART_CHARGE = 0xB2,
    UART_ERROR = 0xFF
};


extern uart_config_t uart_config;

void uart_init(void);
void set_uart_pack( const uint8_t * receivebuffer, int len, uint8_t* data);
void uart_config_car(void);
#endif  // _MY_UART_H